#ifndef YAMLSTREAM_H
#define YAMLSTREAM_H

#include <string>
#include <sstream>
#include <QPair>
#include <QString>

class YamlStream
{
public:
    YamlStream()
    {
        _indentLevel = 0;
    }

    template<typename T>
    YamlStream& operator<<(const QPair<QString, T>& param)
    {
        appendIndentation();
        _stream << param.first.toStdString() << ": ";
        _stream << param.second << std::endl;
        return (*this);
    }

    void        newBlock(const QString& name);
    void        endBlock(void);
    std::string str() { return (_stream.str()); }

    char        SaveToFile(const QString& filepath);

private:
    void              appendIndentation(void);

    unsigned short    _indentLevel;
    std::stringstream _stream;
};

#endif // YAMLSTREAM_H
